<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue-2.2.1.js"></script>
</head>
<body>
  

    <div id="app">
        <button @click="getdiv">mydiv</button>
        <div ref="mydiv" id="mydiv1">mydiv</div>
        <button @click="getcom">mycom</button>
        <login ref="mycom" id="mycom">mycom</login>
    </div>
</body>

<script>
    new Vue({
        el:'#app',
        data:{
           
        },
        methods:{
            getdiv:function(){
                console.log(document.getElementById('mydiv1').innerHTML);

                console.log(this.$refs.mydiv.innerHTML);
            },
            getcom:function(){
                console.log(this.$refs.mycom.subname);
            },
        },

        components:{
            'login':{
                data:function(){
                    return {
                        subname:'子组件名称'
                    }
                },
                template:'<h1>这是一个子组件</h1>',
                
            }
        }
        
    })

</script>
</html>